$().ready(() => {
  let proCheck = Interceptor('/proCheck', 'get', '').data;

  for (let i = 0; i < proCheck.length; i++) {
    let addProject = `
      <div class="list-item" num="${proCheck[i]['id']}">
      <img src="${proCheck[i]['img']}" alt="">
      <h3>${proCheck[i]['name']}</h3>
      <div class="item-amend"></div>
      <p>结束时间：${proCheck[i]['end_time']}</p>
      <div class="item-close"></div>
      <span>查看</span>
      </div>`;
    $('.list-wrap').append(addProject)
  }

  $('.item-amend').click(function (e) {
    console.log($(e.target).parent().attr('num'));
    window.location.href = '../../pages/adminIndex/modificationPoll.html?id=' + $(e.target).parent().attr('num')
  })
  $('.list-item span').click(function (e) {
    window.location.href = '../../pages/detail/adminDetailPage.html?id=' + $(e.target).parent().attr('num')
  })
  $('.item-close').click(function (e){
    let deletePoll = Interceptor('/proDelete','delete',{
      id:$(e.target).parent().attr('num')
    })
    if (deletePoll.code===200){
      $(e.target).parent().remove();
      toolTip(1,'删除成功');
    }else {
      toolTip(0,'删除失败')
    }
  })

})